home *** CD-ROM | disk | FTP | other *** search
/ The Trig Explorer / The Trig Explorer.iso / mac / Explorer / APPS_ANG.dxr / 00024.ls < prev    next >
Encoding:
Text File  |  1998-07-22  |  1.1 KB  |  49 lines

  1. on exitFrame
  2.   go(the frame)
  3. end
  4.  
  5. on enterFrame
  6.   set the constraint of sprite 4 to 3
  7.   set dy to float(the locV of sprite 2 - the locV of sprite 4)
  8.   set dy to -dy
  9.   set dx to float(the locH of sprite 2 - the locH of sprite 4)
  10.   if dx = 0 then
  11.     if dy < 0 then
  12.       set theta1 to float(1.5 * PI)
  13.     else
  14.       set theta1 to float(PI / 2.0)
  15.     end if
  16.   else
  17.     if dx > 0 then
  18.       set theta1 to float(atan(float(dy / dx)))
  19.       if theta1 < 0 then
  20.         set theta1 to float(theta1) + (2.0 * PI)
  21.       end if
  22.     else
  23.       set theta1 to float(atan(float(dy / dx))) + PI
  24.     end if
  25.   end if
  26.   set RR to float(sqrt((dx * dx) + (dy * dy)) / 15.0)
  27.   if RR > 3 then
  28.     set RR to RR * 0.85999999999999999
  29.   else
  30.     if RR > 2 then
  31.       set RR to RR * 0.94999999999999996
  32.     end if
  33.   end if
  34.   set the floatPrecision to 1
  35.   put RR into field "R1"
  36.   if theta1 > PI then
  37.     set theta1 to theta1 - PI
  38.   else
  39.     set theta1 to theta1 + PI
  40.   end if
  41.   set theta2 to theta1 * 180.0 / PI
  42.   if theta2 = 360 then
  43.     put "0.0" into field "theta"
  44.   else
  45.     put theta2 into field "theta"
  46.   end if
  47.   updateStage()
  48. end
  49.